<%@ Page Language="C#" MasterPageFile="~/FiledbookMaster.Master" AutoEventWireup="true" CodeBehind="OperationsOverview.aspx.cs" Inherits="Fieldbook.Testwebsite.User.OperationsOverview" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function ShowHideDiv(on, elemID)
        {
            var divElem = document.getElementById(elemID);
            if (on)
            {
                divElem.style.display = "block";
            }
            else 
            {
                divElem.style.display = "none";
            }
            return false;
        }
    </script>
    <a href="#" onclick="return ShowHideDiv(true, 'divAddOperationCategory')">Add operation category</a> |
    <a href="#" onclick="return ShowHideDiv(true, 'divAddOperation')">Add operation</a>
    <br />
    <br />
    <asp:Label ID="lblOperationStatus" runat="server" EnableViewState="false"/>
    <div id="divAddOperationCategory" style="display:none;">
        <table>
            <tr>
                <td>Description: </td>
                <td>
                    <asp:TextBox ID="txtOperationCategory" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:LinkButton id="linkAddCategory" runat="Server" OnCommand="linkAddCategory_Command" Text="Add"/>
                    <asp:LinkButton id="linkAddCategoryGlobal" runat="Server" 
                        OnCommand="linkAddCategory_Command" 
                        CommandArgument="global"
                        Text="Add global"/>
                    <a href="#" onclick="return ShowHideDiv(false, 'divAddOperationCategory')">Cancel</a>                        
                </td>
            </tr>
        </table>   
        <br/>
    </div> 
    <div id="divAddOperation" style="display:none;">
        <table>
            <tr>
                <td>Category: </td>
                <td>
                    <asp:DropDownList ID="ddlOperationCategory" runat="server"
                        DataSourceID="OperationCategoriesODS"
                        DataValueField="CategoryID"
                        DataTextField="Description"
                        />
                </td>
            </tr>
            <tr>
                <td>Description: </td>
                <td>
                    <asp:TextBox ID="txtDescription" runat="server" />
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <asp:LinkButton id="addOperatoin" runat="Server" OnCommand="linkAddOperation_Command" Text="Add"/>
                    <asp:LinkButton id="addGlobalOperation" runat="Server" 
                        OnCommand="linkAddOperation_Command" 
                        CommandArgument="global"
                        Text="Add global"/>
                    <a href="#" onclick="return ShowHideDiv(false, 'divAddOperation')">Cancel</a>
                </td>
            </tr>
            
        </table>
    </div>     
    <asp:GridView ID="dgvOperationCategories" runat="server" AutoGenerateColumns="False" 
                  DataSourceID="OperationCategoriesODS" 
                  DataKeyNames="CategoryID"
                  OnSelectedIndexChanged="DgvOperationCategories_SelectedIndexChanged">
        <Columns>
            <asp:CommandField ShowSelectButton="True" />
            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
        </Columns>
    </asp:GridView>
    <br />
    <asp:GridView ID="dgvOperations" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
        </Columns>
    </asp:GridView>
    <asp:ObjectDataSource ID="OperationCategoriesODS" runat="server" TypeName="Fieldbook.Business.OperationController" SelectMethod="LoadOperationCategories">
        <SelectParameters>
            <asp:SessionParameter Name="userID" Type="Int64" SessionField="userID" />
        </SelectParameters>
    </asp:ObjectDataSource>
</asp:Content>
